/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package traffic.light.simulator.town.unity;

import java.awt.Color;
import java.awt.Graphics;
import traffic.light.simulator.util.IDrawable;

/**
 *
 *
 */
public abstract class TownElement implements IDrawable {
    //hauteur et largeur en pixel

    protected static int sizeOfElement;
    protected int absoluteX;
    protected int absoluteY;
    private Color color;

    public TownElement(int absoluteX, int absoluteY, Color color) {
        this.absoluteX = absoluteX;
        this.absoluteY = absoluteY;
        this.color = color;
    }

    public static int getSize() {
        return sizeOfElement;
    }

    public static void setSize(int size) {
        sizeOfElement = size;
    }

    public int getAbsX() {
        return absoluteX;
    }

    public int getAbsY() {
        return absoluteY;
    }

    @Override
    public void draw(Graphics g, boolean editionMode) {
        g.setColor(color);
        g.fillRect(absoluteX, absoluteY, sizeOfElement, sizeOfElement);

        g.setColor(new Color(color.getRed() + 20, color.getGreen() + 20, color.getBlue() + 20));
        if (editionMode) {
            g.drawRect(absoluteX, absoluteY, sizeOfElement, sizeOfElement);
        }
    }

    @Override
    public String toString() {
        return "TownElement : x=" + absoluteX + "; y=" + absoluteY;
    }

    public boolean equals(TownElement te) {
        return te.getAbsX() == absoluteX && te.getAbsY() == absoluteY;
    }
}
